package com.fy.customview.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.ViewGroup;
import android.view.Window;

import com.fy.customview.R;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class CommonDialog extends Dialog {
    public CommonDialog(@NonNull Context context) {
        super(context);
    }

    public CommonDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    protected CommonDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    private void init() {
        Window window = getWindow();
        if (window != null) {
            window.setBackgroundDrawableResource(R.color.transparent);//因为默认的背景有padding，无法全屏，所以要替换背景
            window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);//设置弹窗全屏
        }
        setCancelable(false);//不能通过返回键退出
        setCanceledOnTouchOutside(false);//不能通过点击空白地区退出
    }
}
